home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / djgpp / contrib / pdcurs22 / include / curses.h next >
Encoding:
C/C++ Source or Header  |  1995-01-26  |  54.3 KB  |  1,359 lines

  1. /*
  2. ***************************************************************************
  3. * This file comprises part of PDCurses. PDCurses is Public Domain software.
  4. * You may use this code for whatever purposes you desire. This software
  5. * is provided AS IS with NO WARRANTY whatsoever.
  6. * Should this software be used in another application, an acknowledgement
  7. * that PDCurses code is used would be appreciated, but is not mandatory.
  8. *
  9. * Any changes which you make to this software which may improve or enhance
  10. * it, should be forwarded to the current maintainer for the benefit of 
  11. * other users.
  12. *
  13. * The only restriction placed on this code is that no distribution of
  14. * modified PDCurses code be made under the PDCurses name, by anyone
  15. * other than the current maintainer.
  16. * See the file maintain.er for details of the current maintainer.
  17. ***************************************************************************
  18. */
  19. /* 
  20. $Id$
  21. */
  22. /*
  23. *----------------------------------------------------------------------
  24. *                PDCurses
  25. *----------------------------------------------------------------------
  26. * MH
  27. *    950126    2.2    Added more System V R4 functions
  28. *
  29. *            Added beta Xwindows port
  30. *
  31. *            Changed chtype to long
  32. *
  33. *            Incorporated panels library
  34. *
  35. *            Support for more and newer versions of compilers
  36. *
  37. * MH
  38. *    930531    2.1    Added support for djgpp
  39. *
  40. *            Added beta Unix version
  41. *
  42. *            Added OS/2 DLL support.
  43. *
  44. *            Changed behaviour of overlay(), overwrite() and typeahead()
  45. *
  46. *    921120    2.0    Changed #if to #ifdef/#if defined to make it
  47. *            easier to add new platforms/compilers.
  48. *
  49. *            Added System V colour support.
  50. *
  51. *            Added OS/2 port.
  52. *-------
  53. * Frotz
  54. *    911221    2.0 pre-beta    Changed back from short to int. (int is the
  55. *            correct size for the default platform.  Short
  56. *            might be too short on some platforms.  This
  57. *            is more portable.  I, also, made this mistake.)
  58. *
  59. *            Many functions are now macros.  If you want
  60. *            the real thing, #undef the macro. (X/Open
  61. *            requirement.)
  62. *
  63. *            Merged many sources into current release.
  64. *
  65. *            Added many X/Open routines (not quite all yet).
  66. *
  67. *            Added internal documentation to all routines.
  68. *
  69. *            Added a HISTORY file to the environment.
  70. *
  71. *            Added a CONTRIB file to the environment.
  72. *-------
  73. * bl    900114    1.4    Window origin mod in overlay() and overwrite(), on
  74. *            public (and very reasonable) request. Swapped
  75. *            #define'd values of OK and ERR; OK now 1, and
  76. *            ERR is 0/NULL. Conforms better to UNIX
  77. *            versions.  borderchars[] removed from WINDOW
  78. *            struct since the border() functions were
  79. *            redefined. Use of short wherever possible.
  80. *            Portability improvements, mispelled name of
  81. *            [w]setscrreg().
  82. *
  83. *    881005    1.3    All modules lint-checked with MSC '-W3' and
  84. *            turbo'C' '-w -w-pro' switches. Support for
  85. *            border(), wborder() functions.
  86. *
  87. *    881002    1.2    Rcsid[] string in all modules, for maintenance.
  88. *
  89. *    880306    1.1    'Raw' output routines, revision info in curses.h.
  90. *
  91. *    870515    1.0    Initial Release.
  92. *
  93. *----------------------------------------------------------------------
  94. */
  95.  
  96. #ifndef  __PDCURSES__
  97. #define    __PDCURSES__ 1
  98.  
  99. /*man-start*********************************************************************
  100.  
  101. All defines are "defined" here.  All compiler and environment
  102. specific definitions are defined into generic class defines.
  103. These defines are to be given values so that the code can
  104. rely on #if, rather than a complicated set of #if defined() or
  105. #ifdefs...
  106.  
  107. PDCurses definitions list:  (Only define those needed)
  108.  
  109.     REGISTERWINDOWS True for auto window update registery.
  110.     FAST_VIDEO      True if display is memory mapped, or
  111.                     we can utilize the fast video update routines.
  112.     DOS             True if compiling for DOS.
  113.     OS2             True if compiling for OS/2.
  114.     FLEXOS          True if compiling for Flexos.
  115.     HC              True if using a Metaware compiler.
  116.     TC              True if using a Borland compiler.
  117.     MSC             True if using a Microsoft compiler.
  118.     ANSI            True if the compiler supports ANSI C and
  119.                     (full or mixed) prototypes.
  120.     CPLUSPLUS       True if the compiler supports C++.
  121.  
  122. PDCurses portable platform definitions list:
  123.  
  124.     PDCurses        Enables access to PDCurses-only routines.
  125.     XOPEN           Always true.
  126.     SYSV            True if you are compiling for SYSV portability.
  127.     BSD             True if you are compiling for BSD portability.
  128.     INTERNAL        Enables access to internal PDCurses routines.
  129.     PDCURSES_WCLR   Makes behaviour of wclrtoeol() and wclrtoeof()
  130.                     unique to PDCurses. By default Unix behavior is set.
  131.                     See notes in wclrtoeol() and wclrtoeof().
  132. **man-end**********************************************************************/
  133.  
  134. #define    PDCURSES    1    /* PDCurses-only routines    */
  135. #define    XOPEN        1    /* X/Open Curses routines    */
  136. #define    SYSV        1    /* System V Curses routines    */
  137. #define    BSD        1    /* BSD Curses routines        */
  138. #define    INTERNAL    1    /* PDCurses Internal routines    */
  139.  
  140.  
  141. /*----------------------------------------
  142. *       BORLAND COMPILERS       Turbo C[++], Borland C[++]
  143. *
  144. *       Borland definitions:
  145. *               TC
  146. *               DOS
  147. *               OS2
  148. *               CPLUSPLUS
  149. *
  150. *               __TURBOC__, __MSDOS__ and __OS2__ are predefined by compiler.
  151. */
  152. #ifdef __TURBOC__              /* Borland gives defines this as a value*/
  153. #  define TC    __TURBOC__     /* Define a value for TC                */
  154. #  define ANSI  1              /* Borland supports ANSI C prototypes   */
  155. #  ifdef __MSDOS__
  156. #    define DOS 6              /* Major release of DOS supported       */
  157. #    define CHTYPE_LONG        /* Use "long" chtype                    */
  158. #    include <bios.h>
  159. #    include <dos.h>
  160. #  endif
  161. #  ifdef __OS2__
  162. #    define OS2 3              /* Major release of OS/2 supported      */
  163. #    define CHTYPE_LONG        /* Use "long" chtype                    */
  164. #    define INCL_VIO
  165. #    define INCL_KBD
  166. #    include <os2.h>
  167. #  endif
  168. #  if __TURBOC__ >= 0x290
  169. #    ifdef  __BCPLUSPLUS__
  170. #      define CPLUSPLUS   1    /* Define that we are compiling C++.    */
  171. #    endif
  172. #    ifdef  __TCPLUSPLUS__
  173. #      define CPLUSPLUS   1    /* Define that we are compiling C++.    */
  174. #    endif
  175. #    ifdef  __CPLUSPLUS__
  176. #      define CPLUSPLUS   1    /* Define that we are compiling C++.    */
  177. #    endif
  178. #  endif
  179. #endif
  180.  
  181.  
  182. /*----------------------------------------
  183. *       METAWARE COMPILERS      High C
  184. *
  185. *       Metaware definitions:
  186. *               HC
  187. *               DOS
  188. *               FLEXOS
  189. */
  190. #ifdef __HIGHC__
  191. #  define HC    1
  192. #  pragma off(prototype_override_warnings)
  193. #  define ANSI  1              /* Metaware supports ANSI C prototypes  */
  194. #  ifdef __MSDOS__
  195. #    define DOS 6              /* Major release of DOS supported       */
  196. #    include <bios.h>
  197. #    include <dos.h>
  198. #  endif
  199. #  ifdef __FLEXOS__            /* define this on the command line      */
  200. #    define FLEXOS 2           /* or latest major release value.       */
  201. #  endif
  202. #endif
  203.  
  204. /*----------------------------------------
  205. *       MICROSOFT COMPILERS      MSC
  206. *
  207. *       Microsoft definitions:
  208. *               MSC
  209. *               DOS || OS2
  210. */
  211. #ifdef _MSC_VER                                 /* defined by compiler */
  212. #  define MSC   1
  213. #  define ANSI  1              /* Microsoft supports ANSI C prototypes */
  214. #  ifdef __OS2__                /* You will have to define in makefile */
  215. #    define USE_OS2_H 1             /* Use the os2.h for the compiler  */
  216. #    define OS2 3                   /* Major release of OS/2 supported */
  217. #    define INCL_VIO
  218. #    define INCL_KBD
  219. #    include <os2.h>
  220. #    define NO_VSSCANF 1 /* define if no vsscanf() function in library */
  221. #    define FARKeyword far
  222. #    define APIRET USHORT
  223. #  else                            /* no __OS2__ define, so assume DOS */
  224. #    define DOS 6                    /* Major release of DOS supported */
  225. #    include <bios.h>
  226. #    include <dos.h>
  227. #    define NO_VSSCANF 1 /* define if no vsscanf() function in library */
  228. #  endif
  229. #endif
  230.  
  231. /*----------------------------------------
  232. *       MICROSOFT QUICK C COMPILERS      QC
  233. *
  234. */
  235. #ifdef _QC                                 /* defined by compiler */
  236. #  define MSC   1
  237. #  define ANSI  1              /* QuickC supports ANSI C prototypes */
  238. #  define DOS 6                    /* Major release of DOS supported */
  239. #  include <bios.h>
  240. #  include <dos.h>
  241. #  define NO_VSSCANF 1 /* define if no vsscanf() function in library */
  242. #endif
  243.  
  244. /*----------------------------------------
  245. *       TOPSPEED compilers     TSC
  246. *
  247. *       TOPSPEED definitions:
  248. *               TSC
  249. *               DOS || OS2
  250. */
  251. #ifdef __TSC__                   /* You may have to define in makefile */
  252. #  define TSC   1
  253. #  define ANSI  1              /* TopSpeed supports ANSI C prototypes  */
  254. #  define CHTYPE_LONG          /* Use "long" chtype                    */
  255. #  ifdef __OS2__
  256. #    define OS2 3                   /* Major release of OS/2 supported */
  257. #    include <cursos2.h>
  258. #  endif
  259. #endif
  260.  
  261. /*----------------------------------------
  262. *       IBM C Set/2 Compiler   CSET2
  263. *
  264. *       IBM definitions:
  265. *               CSET2
  266. *               OS2
  267. */
  268. #ifdef __IBMC__
  269. #  define CSET2 1
  270. #  define ANSI  1               /* C Set/2 supports ANSI C prototypes  */
  271. #  define CHTYPE_LONG          /* Use "long" chtype                    */
  272. #  ifdef __OS2__
  273. #    define OS2 3                   /* Major release of OS/2 supported */
  274. #    define NO_VSSCANF 1 /* define if no vsscanf() function in library */
  275. #    define INCL_VIO
  276. #    define INCL_KBD
  277. #    include <os2.h>
  278. #  endif
  279. #endif
  280.  
  281. /*----------------------------------------
  282. *       GNU compilers     emx
  283. *
  284. *       emx definitions:
  285. *               EMX
  286. *               OS2
  287. */
  288. #ifdef __EMX__                   /* You may have to define in makefile */
  289. #  define EMX   1
  290. #  define ANSI  1                    /* GNU supports ANSI C prototypes */
  291. #  define CHTYPE_LONG                             /* Use "long" chtype */
  292. #  define __OS2__                      /* EMX does not define this :-( */
  293. #  define OS2 3                     /* Major release of OS/2 supported */
  294. #  define CURSES__32BIT__
  295. #  include <cursos2.h>
  296. #endif
  297.  
  298. /*----------------------------------------
  299. *       GNU compilers     djgpp
  300. *
  301. *        djgpp definitions:
  302. *                GO32
  303. *                DOS
  304. */
  305. #ifdef __GO32__                   /* You may have to define in makefile */
  306. #  define GO32    1
  307. #  define ANSI  1                   /* GNU supports ANSI C prototypes  */
  308. #  define CHTYPE_LONG          /* Use "long" chtype                    */
  309. #  define DOS    6
  310. #     include <dos.h>
  311. #  ifdef __FLEXOS__            /* define this on the command line       */
  312. #    define FLEXOS 2           /* or latest major release value.       */
  313. #  endif
  314. #  define CURSES__32BIT__
  315. #  ifdef _cplusplus
  316. #     define CPLUSPLUS 1
  317. #  endif
  318. #  define NO_VSSCANF 1 /* define if no vsscanf() function in library */
  319. #endif
  320.  
  321. /*----------------------------------------
  322. *       Watcom C/C++ 10.0 compiler
  323. *
  324. *       WATCOM definitions:
  325. *               WATCOMC
  326. *               OS2
  327. */
  328. #ifdef __WATCOMC__
  329. #  define WATCOMC  1
  330. #  define ANSI  1          /* Watcom C/386 supports ANSI C prototypes  */
  331. #  define CURSES__32BIT__
  332. #  define NO_MEMORY_H        /* this compiler does not have a memory.h */
  333. #  define CHTYPE_LONG          /* Use "long" chtype                    */
  334. #  ifdef __DOS__
  335. #    define DOS 6              /* Major release of DOS supported       */
  336. #    include <bios.h>
  337. #    include <dos.h>
  338. #    include <i86.h>
  339. #    ifdef __386__
  340. #      define int86 int386
  341. #      define int86x int386x
  342. #    endif
  343. #  endif
  344. #  ifdef __OS2__
  345. #    define OS2 3                   /* Major release of OS/2 supported */
  346. #    define CURSES__32BIT__
  347. #    define NO_MEMORY_H      /* this compiler does not have a memory.h */
  348. #    define INCL_VIO
  349. #    define INCL_KBD
  350. #    include <os2.h>
  351. #  endif
  352. #endif
  353.  
  354. /*----------------------------------------
  355. *       gcc under UNIX
  356. *
  357. *       GNU definitions:
  358. *               UNIX
  359. */
  360. #ifdef UNIX
  361. #  define ANSI  1                 /* GNU C supports ANSI C prototypes  */
  362. #  ifdef SUNOS
  363. #    define NO_VSSCANF
  364. #    define NO_MEMMOVE
  365. #    undef BSD
  366. #  endif
  367. #  ifdef LINUX
  368. #    undef BSD
  369. #  endif
  370. #endif
  371.  
  372. /*----------------------------------------
  373. *       MicroWay NDP C/C++ 386 4.2.0 compiler
  374. */
  375. #ifdef MX386
  376. #  define ANSI    1
  377. #  define NDP    1
  378. #  include     <bios.h>
  379. #  ifdef DOS
  380. #    define MK_FP(seg,ofs)    ( (((int) (seg)) << 4) + ((int) (ofs)) )
  381. #    ifdef __i860
  382.        typedef void _int;
  383. #    else
  384.        typedef int      _int;
  385. #    endif
  386. #  endif
  387. #    define NO_VSSCANF 1 /* define if no vsscanf() function in library */
  388. #endif
  389.  
  390. #ifdef NO_MEMMOVE
  391. #define memmove PDC_memmove
  392. #endif
  393.  
  394. /*---------------------------------------------------------------------*/
  395. #include <stdio.h>        /* Required by X/Open usage below    */
  396. /*----------------------------------------------------------------------
  397.  *
  398.  *    PDCurses Manifest Constants
  399.  *
  400.  */
  401. #ifndef FALSE            /* booleans         */
  402. #  define    FALSE    0
  403. #endif
  404. #ifndef    TRUE            /* booleans         */
  405. #  define    TRUE    !FALSE
  406. #endif
  407. #ifndef    NULL
  408. #  define NULL    ((void*)0)    /* Null pointer         */
  409. #endif
  410. #ifndef    ERR
  411. #  define     ERR    0        /* general error flag     */
  412. #endif
  413. #ifndef    OK
  414. #  define     OK    1        /* general OK flag     */
  415. #endif
  416.  
  417.  
  418.  
  419.  
  420. /*----------------------------------------------------------------------
  421.  *
  422.  *    PDCurses Type Declarations
  423.  *
  424.  */
  425. typedef unsigned char bool;    /* PDCurses Boolean type    */
  426. #if defined (XCURSES)
  427. #ifndef CHTYPE_LONG
  428. #define CHTYPE_LONG
  429. #endif
  430. #endif
  431.  
  432. #ifdef CHTYPE_LONG
  433. typedef unsigned long chtype;    /* 16-bit attr + 16-bit char    */
  434. #else
  435. typedef unsigned short chtype;    /* 8-bit attr + 8-bit char    */
  436. #endif
  437.  
  438.  
  439.  
  440.  
  441. /*----------------------------------------------------------------------
  442.  *
  443.  *    PDCurses Structure Definitions:
  444.  *
  445.  */
  446. typedef struct _win        /* definition of a window.       */
  447. {
  448.     int    _cury;        /* current pseudo-cursor       */
  449.     int    _curx;
  450.     int    _maxy;        /* max window coordinates       */
  451.     int    _maxx;
  452.     int    _pmaxy;        /* max physical size           */
  453.     int    _pmaxx;
  454.     int    _begy;        /* origin on screen           */
  455.     int    _begx;
  456.     int    _lastpy;    /* last y coordinate of upper left pad display area */
  457.     int    _lastpx;    /* last x coordinate of upper left pad display area */
  458.     int    _lastsy1;    /* last upper y coordinate of screen window for pad */
  459.     int    _lastsx1;    /* last upper x coordinate of screen window for pad */
  460.     int    _lastsy2;    /* last lower y coordinate of screen window for pad */
  461.     int    _lastsx2;    /* last lower x coordinate of screen window for pad */
  462.     int    _flags;        /* window properties           */
  463.     chtype    _attrs;        /* standard A_STANDOUT attributes and colors  */
  464.     chtype    _bkgd;        /* wrs(4/6/93) background, normally blank */
  465.     int    _tabsize;    /* tab character size           */
  466.     bool    _clear;        /* causes clear at next refresh       */
  467.     bool    _leave;        /* leaves cursor as it happens       */
  468.     bool    _scroll;    /* allows window scrolling       */
  469.     bool    _nodelay;    /* input character wait flag       */
  470.     bool    _immed;    /* immediate update flag       */
  471.     bool    _use_keypad;    /* flags keypad key mode active       */
  472.     bool    _use_idl;    /* True if Ins/Del line can be used*/
  473.     bool    _use_idc;    /* True if Ins/Del character can be used*/
  474.     chtype**_y;        /* pointer to line pointer array   */
  475.     int*    _firstch;    /* first changed character in line */
  476.     int*    _lastch;    /* last changed character in line  */
  477.     int    _tmarg;    /* top of scrolling region       */
  478.     int    _bmarg;    /* bottom of scrolling region       */
  479.     char*    _title;        /* window title               */
  480.     char    _title_ofs;    /* window title offset from left   */
  481.     chtype    _title_attr;    /* window title attributes       */
  482.     chtype    _blank;        /* window's blank character       */
  483.     int    _parx, _pary;    /* coords relative to parent (0,0) */
  484. struct    _win*    _parent;    /* subwin's pointer to parent win  */
  485. }    WINDOW;
  486.  
  487.  
  488.  
  489. /*----------------------------------------------------------------------
  490. *
  491. *    Private structures that are necessary for correct
  492. *    macro construction.
  493. *
  494. */
  495.  
  496. #ifdef    REGISTERWINDOWS
  497. typedef struct _ref        /* Refresh Window Structure     */
  498. {
  499.     WINDOW*    win;
  500. struct    _ref*    next;
  501. struct    _ref*    tail;
  502. }    ACTIVE;
  503.  
  504. typedef struct _wins
  505. {
  506.     WINDOW*        w;    /* pointer to a visible window        */
  507.     struct _wins*    next;    /* Next visible window pointer        */
  508.     struct _wins*    prev;    /* Next visible window pointer        */
  509.     struct _wins*    tail;    /* Last visible window pointer        */
  510.                 /* Only head window (stdscr) has    */
  511.                 /* a valid tail pointer.        */
  512. }    WINDS;
  513. #endif
  514.  
  515.  
  516.  
  517.  
  518. typedef struct
  519. {
  520.     bool    alive;        /* TRUE if already opened.        */
  521.     bool    autocr;        /* if lf -> crlf            */
  522.     bool    cbreak;        /* if terminal unbuffered        */
  523.     bool    echo;        /* if terminal echo            */
  524.     bool    raw_inp;    /* raw input mode (v. cooked input) */
  525.     bool    raw_out;    /* raw output mode (7 v. 8 bits)    */
  526.     bool    refrbrk;    /* if premature refresh brk allowed */
  527.     bool    orgcbr;        /* original MSDOS ^-BREAK setting   */
  528.     bool    visible_cursor; /* TRUE if cursor is visible        */
  529.     bool    audible;    /* FALSE if the bell is visual        */
  530.     bool    full_redraw;    /* TRUE for bad performance        */
  531.     bool    direct_video;    /* Allow Direct Screen Memory writes*/
  532.     bool    mono;        /* TRUE if current screen is mono.  */
  533.     bool    sizeable;    /* TRUE if adapter is resizeable.   */
  534.     bool    bogus_adapter;    /* TRUE if adapter has insane values*/
  535.     bool    shell;        /* TRUE if reset_prog_mode() needs  */
  536.                 /*    to be called.            */
  537.     chtype    blank;        /* Background character            */
  538.     chtype    orig_attr;    /* Original screen attributes        */
  539.     int    cursrow;    /* position of physical cursor        */
  540.     int    curscol;    /* position of physical cursor        */
  541.     int    cursor;        /* Current Cursor definition        */
  542.     int    visibility;        /* Visibility of cursor    */
  543.     int    video_page;    /* Current PC video page        */
  544.     int    orig_emulation; /* Original cursor emulation value  */
  545.     int    orig_cursor;    /* Original cursor size            */
  546.     int    font;        /* default font size            */
  547.     int    orig_font;    /* Original font size            */
  548.     int    lines;        /* New value for LINES            */
  549.     int    cols;        /* New value for COLS            */
  550.     int    emalloc;    /* 0x0C0C if initscr() is to reset  */
  551.                 /*     this value to TRUE;        */
  552.                 /* TRUE only if emalloc()/ecalloc() */
  553.                 /*     are is to be used;        */
  554.                 /* FALSE if malloc()/calloc() are   */
  555.                 /*     to be used.            */
  556. #ifdef OS2
  557. # ifdef EMXVIDEO            /* nop if using EMX builtins */
  558.     int tahead;             /* Type-ahead value */
  559.     int adapter;            /* Screen type    */
  560. # else
  561.     VIOMODEINFO scrnmode;    /* default screen mode            */
  562.     VIOCONFIGINFO adapter;    /* Screen type                */
  563. # endif
  564. #endif
  565. #ifdef DOS
  566.     int    scrnmode;    /* default screen mode            */
  567.     int    adapter;    /* Screen type                */
  568.     unsigned video_seg;    /* video base segment            */
  569.     unsigned video_ofs;    /* video base offset            */
  570. #endif
  571. #if defined (XCURSES)
  572.     int    adapter;    /* Screen type                */
  573. #endif
  574. #ifdef UNIX
  575.     int    adapter;    /* Screen type                */
  576.     int number_keys;    /* number of function keys */
  577.     char *key_seq[200];    /* key sequence ptr for function keys */
  578.     int key_num[200];    /* key numbers for function keys */
  579. #endif
  580. #ifdef    REGISTERWINDOWS
  581.     WINDS*    visible;    /* List of visible windows        */
  582.     bool    refreshall;    /* Refresh all registered windows?  */
  583. #endif
  584.  
  585. }    SCREEN;
  586.  
  587.  
  588.  
  589.  
  590.  
  591. /* external variables */
  592. extern    int    LINES;        /* terminal height        */
  593. extern    int    COLS;        /* terminal width        */
  594. extern    WINDOW*    stdscr;        /* the default screen window    */
  595. extern    SCREEN    _cursvar;    /* curses variables        */
  596.  
  597. #if    defined (INTERNAL) | defined (CURSES_LIBRARY)
  598. extern    WINDOW*    curscr;        /* the current screen image    */
  599. extern    int    _default_lines;    /* For presetting maximum lines    */
  600. #endif
  601.  
  602. #ifdef    REGISTERWINDOWS
  603. extern    ACTIVE*    CurWins;    /* Currently Visible Windows    */
  604. #endif
  605.  
  606.  
  607.  
  608.  
  609. /*man-start*********************************************************************
  610.  
  611. PDCurses Text Attributes:
  612.  
  613. To include colour in PDCurses, a number of things had to be sacrificed
  614. from the strict Unix and System V support.
  615. The main problem is fitting all character attributes and colour into
  616. an unsigned char (all 8 bits!). On System V, chtype is a long on
  617. PDCurses it is a short int.
  618.  
  619. The following is the structure of a win->_attrs chtype:
  620.  
  621. -------------------------------------------------
  622. |15|14|13|12|11|10| 9| 8| 7| 6| 5| 4| 3| 2| 1| 0|
  623. -------------------------------------------------
  624.  colour number |  attrs |   character eg 'a'
  625.  
  626. the high order char is an index into an array of physical colours
  627. (defined in INITPAIR.c). 32 (5 bits) foreground/background colour
  628. combinations combined with 8 (3 bits) attribute modifiers are
  629. available.
  630.  
  631. The available attribute enhancers are bold, reverse and blink.
  632. All other Unix attributes have no effect as attributes. This
  633. limitation may be overcome in future releases by expanding chtype
  634. to a long.
  635.  
  636. **man-end**********************************************************************/
  637.  
  638. /* Video attribute definitions. */
  639. #ifdef CHTYPE_LONG
  640. #define A_NORMAL            0x00000000L
  641. #define A_STANDOUT          0x00A00000L
  642. #define A_BOLD              0x00800000L
  643. #define A_UNDERLINE         0x00100000L
  644. #define A_REVERSE           0x00200000L
  645. #define A_BLINK             0x00400000L
  646. #define A_DIM               0x00020000L
  647. #define A_INVIS             0x00080000L
  648. #define A_PROTECT           0x00010000L
  649. #define A_ALTCHARSET        0x00040000L
  650. #define A_ATTRIBUTES        0xFFFF0000L
  651. #define A_CHARTEXT          0x0000FFFFL
  652. #define A_COLOR             0xFF000000L
  653.  
  654. #else
  655.  
  656. #define A_NORMAL    (chtype)0x0000        /* SysV */
  657. #define A_ALTCHARSET    (chtype)0x0000        /* X/Open    */
  658. #define A_BLINK        (chtype)0x0400        /* X/Open    */
  659. #define A_BLANK        (chtype)0x0000        /* X/Open    */
  660. #define A_BOLD        (chtype)0x0100        /* X/Open    */
  661. #define A_DIM        (chtype)0x0000        /* X/Open    */
  662. #define A_PROTECT    (chtype)0x0000        /* X/Open    */
  663. #define A_REVERSE    (chtype)0x0200        /* X/Open    */
  664. #define A_STANDOUT    ((chtype)(A_REVERSE | A_BOLD))        /* X/Open    */
  665. #define A_UNDERLINE    (chtype)0x0000        /* X/Open    */
  666. #define A_COLOR    (chtype)0xF800        /*System V    */
  667. #define A_CHARTEXT    (chtype)(0xFF)            /* X/Open    */
  668. #define A_ATTRIBUTES    (chtype)(~A_CHARTEXT)            /* X/Open    */
  669. #endif
  670.  
  671. #define CHR_MSK        A_CHARTEXT        /* Obsolete    */
  672. #define ATR_MSK        A_ATTRIBUTES    /* Obsolete    */
  673. #define ATR_NRM        A_NORMAL            /* Obsolete    */
  674.  
  675. #ifdef UNIX
  676.  
  677. extern chtype *acs_map;
  678.  
  679. #define ACS_BSSB    (acs_map['l'])
  680. #define ACS_SSBB    (acs_map['m'])
  681. #define ACS_BBSS    (acs_map['k'])
  682. #define ACS_SBBS    (acs_map['j'])
  683. #define ACS_SBSS    (acs_map['u'])
  684. #define ACS_SSSB    (acs_map['t'])
  685. #define ACS_SSBS    (acs_map['v'])
  686. #define ACS_BSSS    (acs_map['w'])
  687. #define ACS_BSBS    (acs_map['q'])
  688. #define ACS_SBSB    (acs_map['x'])
  689. #define ACS_SSSS    (acs_map['n'])
  690.  
  691. #define ACS_ULCORNER    ACS_BSSB
  692. #define ACS_LLCORNER    ACS_SSBB
  693. #define ACS_URCORNER    ACS_BBSS
  694. #define ACS_LRCORNER    ACS_SBBS
  695. #define ACS_RTEE        ACS_SBSS
  696. #define ACS_LTEE        ACS_SSSB
  697. #define ACS_BTEE        ACS_SSBS
  698. #define ACS_TTEE        ACS_BSSS
  699. #define ACS_HLINE       ACS_BSBS
  700. #define ACS_VLINE       ACS_SBSB
  701. #define ACS_PLUS        ACS_SSSS
  702.  
  703. #define ACS_S1    (acs_map['o'])
  704. #define ACS_S9    (acs_map['s'])
  705. #define ACS_DIAMOND    (acs_map['\''])
  706. #define ACS_CKBOARD    (acs_map['a'])
  707. #define ACS_DEGREE    (acs_map['f'])
  708. #define ACS_PLMINUS    (acs_map['g'])
  709. #define ACS_BULLET    (acs_map['~'])
  710. #define ACS_LARROW    (acs_map[','])
  711. #define ACS_RARROW    (acs_map['+'])
  712. #define ACS_DARROW    (acs_map['.'])
  713. #define ACS_UARROW    (acs_map['-'])
  714. #define ACS_BOARD    (acs_map['h'])
  715. #define ACS_LANTERN    (acs_map['i'])
  716. #define ACS_BLOCK    (acs_map['0'])
  717.  
  718. #endif
  719.  
  720. #if defined (XCURSES)
  721. #define ACS_ULCORNER    (chtype)13
  722. #define ACS_LLCORNER    (chtype)14
  723. #define ACS_URCORNER    (chtype)12
  724. #define ACS_LRCORNER    (chtype)11
  725. #define ACS_RTEE    (chtype)21
  726. #define ACS_LTEE    (chtype)22
  727. #define ACS_BTEE    (chtype)23
  728. #define ACS_TTEE    (chtype)24
  729. #define ACS_HLINE    (chtype)18
  730. #define ACS_VLINE    (chtype)25
  731. #define ACS_PLUS    (chtype)15
  732. #define ACS_S1    (chtype)'*'
  733. #define ACS_S9    (chtype)'*'
  734. #define ACS_DIAMOND    (chtype)1
  735. #define ACS_CKBOARD    (chtype)2
  736. #define ACS_DEGREE    (chtype)7
  737. #define ACS_PLMINUS    (chtype)8
  738. #define ACS_BULLET    (chtype)'*'
  739. #define ACS_LARROW    (chtype)'<'
  740. #define ACS_RARROW    (chtype)'>'
  741. #define ACS_DARROW    (chtype)'v'
  742. #define ACS_UARROW    (chtype)'^'
  743. #define ACS_BOARD    (chtype)'*'
  744. #define ACS_LANTERN    (chtype)'*'
  745. #define ACS_BLOCK    (chtype)'*'
  746. #endif
  747.  
  748. #if defined(DOS) || defined(OS2)
  749. /* ALTCHARSET definitions from jshumate@wrdis01.robins.af.mil */
  750. #define ACS_ULCORNER    (chtype)0xda            /* SysV        */
  751. #define ACS_LLCORNER    (chtype)0xc0            /* SysV        */
  752. #define ACS_URCORNER    (chtype)0xbf            /* SysV        */
  753. #define ACS_LRCORNER    (chtype)0xd9            /* SysV        */
  754. #define ACS_RTEE    (chtype)0xb4            /* SysV        */
  755. #define ACS_LTEE    (chtype)0xc3            /* SysV        */
  756. #define ACS_BTEE    (chtype)0xc1            /* SysV        */
  757. #define ACS_TTEE    (chtype)0xc2            /* SysV        */
  758. #define ACS_HLINE    (chtype)0xc4            /* SysV        */
  759. #define ACS_VLINE    (chtype)0xb3            /* SysV        */
  760. #define ACS_PLUS    (chtype)0xc5            /* SysV        */
  761. #define ACS_S1    (chtype)0x2d            /* SysV        */
  762. #define ACS_S9    (chtype)0x5f            /* SysV        */
  763. #define ACS_DIAMOND    (chtype)0xc5            /* SysV        */
  764. #define ACS_CKBOARD    (chtype)0xb2            /* SysV        */
  765. #define ACS_DEGREE    (chtype)0xf8            /* SysV        */
  766. #define ACS_PLMINUS    (chtype)0xf1            /* SysV        */
  767. #define ACS_BULLET    (chtype)0xf9            /* SysV        */
  768. #define ACS_LARROW    (chtype)0x3c            /* SysV        */
  769. #define ACS_RARROW    (chtype)0x3e            /* SysV        */
  770. #define ACS_DARROW    (chtype)0x76            /* SysV        */
  771. #define ACS_UARROW    (chtype)0x5e            /* SysV        */
  772. #define ACS_BOARD    (chtype)0x23            /* SysV        */
  773. #define ACS_LANTERN    (chtype)0x23            /* SysV        */
  774. #define ACS_BLOCK    (chtype)0x23            /* SysV        */
  775.  
  776. /* the following definitions can be used if you have set raw_output()
  777.    or are using the PDCurses *raw*() functions                        */
  778. #if 0
  779. #define ACS_DIAMOND    (chtype)0x04            /* SysV        */
  780. #define ACS_LARROW    (chtype)0x1b            /* SysV        */
  781. #define ACS_RARROW    (chtype)0x1a            /* SysV        */
  782. #define ACS_DARROW    (chtype)0x19            /* SysV        */
  783. #define ACS_UARROW    (chtype)0x18            /* SysV        */
  784. #define ACS_BOARD    (chtype)0xb0            /* SysV        */
  785. #define ACS_LANTERN    (chtype)0x0f            /* SysV        */
  786. #define ACS_BLOCK    (chtype)0xdb            /* SysV        */
  787. #endif
  788. #endif
  789.  
  790. /* colour attributes */
  791. #if defined (XCURSES)
  792. #  define COLOR_BLACK        0
  793. #  define COLOR_RED        1
  794. #  define COLOR_GREEN        2
  795. #  define COLOR_YELLOW        3
  796. #  define COLOR_BLUE        4
  797. #  define COLOR_MAGENTA        5
  798. #  define COLOR_CYAN        6
  799. #  define COLOR_WHITE        7
  800. #else
  801. #  define COLOR_BLACK        0
  802. #  define COLOR_BLUE        1
  803. #  define COLOR_GREEN        2
  804. #  define COLOR_CYAN        3
  805. #  define COLOR_RED        4
  806. #  define COLOR_MAGENTA        5
  807. #  define COLOR_YELLOW        6
  808. #  define COLOR_WHITE        7
  809. #endif
  810.  
  811. #ifdef CHTYPE_LONG
  812. #define COLOR_PAIR(n)  ((chtype)(n) << 24)
  813. #define PAIR_NUMBER(n) (((n) & A_COLOR) >> 24)
  814. #else
  815. #define COLOR_PAIR(n)  (((n) << 11) & A_ATTRIBUTES)
  816. #define PAIR_NUMBER(n) (((n) & A_COLOR) >> 11)
  817. #endif
  818.  
  819. extern int COLORS,COLOR_PAIRS;
  820. /*----------------------------------------------------------------------
  821.  *
  822.  *    Function and Keypad Key Definitions.
  823.  *    Many are just for compatibility.
  824.  *
  825.  */
  826. #define KEY_MIN         0x101   /* Minimum curses key value      */
  827. #define KEY_BREAK       0x101   /* Not on PC KBD                 */
  828. #define KEY_DOWN        0x102   /* Down arrow key                */
  829. #define KEY_UP          0x103   /* Up arrow key                  */
  830. #define KEY_LEFT        0x104   /* Left arrow key                */
  831. #define KEY_RIGHT       0x105   /* Right arrow key               */
  832. #define KEY_HOME        0x106   /* home key                      */
  833. #define KEY_BACKSPACE   0x107   /* not on pc                     */
  834. #define KEY_F0          0x108   /* function keys. space for      */
  835. #define KEY_F(n)    (KEY_F0+(n))/* 64 keys are reserved.         */
  836. #define KEY_DL          0x148   /* not on pc                     */
  837. #define KEY_IL          0x149   /* insert line                   */
  838. #define KEY_DC          0x14a   /* delete character              */
  839. #define KEY_IC          0x14b   /* insert char or enter ins mode */
  840. #define KEY_EIC         0x14c   /* exit insert char mode         */
  841. #define KEY_CLEAR       0x14d   /* clear screen                  */
  842. #define KEY_EOS         0x14e   /* clear to end of screen        */
  843. #define KEY_EOL         0x14f   /* clear to end of line          */
  844. #define KEY_SF          0x150   /* scroll 1 line forward         */
  845. #define KEY_SR          0x151   /* scroll 1 line back (reverse)  */
  846. #define KEY_NPAGE       0x152   /* next page                     */
  847. #define KEY_PPAGE       0x153   /* previous page                 */
  848. #define KEY_STAB        0x154   /* set tab                       */
  849. #define KEY_CTAB        0x155   /* clear tab                     */
  850. #define KEY_CATAB       0x156   /* clear all tabs                */
  851. #define KEY_ENTER       0x157   /* enter or send (unreliable)    */
  852. #define KEY_SRESET      0x158   /* soft/reset (partial/unreliable)*/
  853. #define KEY_RESET       0x159   /* reset/hard reset (unreliable) */
  854. #define KEY_PRINT       0x15a   /* print/copy                    */
  855. #define KEY_LL          0x15b   /* home down/bottom (lower left) */
  856. #define KEY_ABORT       0x15c   /* abort/terminate key (any)     */
  857. #define KEY_SHELP       0x15d   /* short help                    */
  858. #define KEY_LHELP       0x15e   /* long help                     */
  859. #define KEY_BTAB        0x15f   /* Back tab key                  */
  860. #define KEY_BEG         0x160   /* beg(inning) key               */
  861. #define KEY_CANCEL      0x161   /* cancel key                    */
  862. #define KEY_CLOSE       0x162   /* close key                     */
  863. #define KEY_COMMAND     0x163   /* cmd (command) key             */
  864. #define KEY_COPY        0x164   /* copy key                      */
  865. #define KEY_CREATE      0x165   /* create key                    */
  866. #define KEY_END         0x166   /* end key                       */
  867. #define KEY_EXIT        0x167   /* exit key                      */
  868. #define KEY_FIND        0x168   /* find key                      */
  869. #define KEY_HELP        0x169   /* help key                      */
  870. #define KEY_MARK        0x16a   /* mark key                      */
  871. #define KEY_MESSAGE     0x16b   /* message key                   */
  872. #define KEY_MOVE        0x16c   /* move key                      */
  873. #define KEY_NEXT        0x16d   /* next object key               */
  874. #define KEY_OPEN        0x16e   /* open key                      */
  875. #define KEY_OPTIONS     0x16f   /* options key                   */
  876. #define KEY_PREVIOUS    0x170   /* previous object key           */
  877. #define KEY_REDO        0x171   /* redo key                      */
  878. #define KEY_REFERENCE   0x172   /* ref(erence) key               */
  879. #define KEY_REFRESH     0x173   /* refresh key                   */
  880. #define KEY_REPLACE     0x174   /* replace key                   */
  881. #define KEY_RESTART     0x175   /* restart key                   */
  882. #define KEY_RESUME      0x176   /* resume key                    */
  883. #define KEY_SAVE        0x177   /* save key                      */
  884. #define KEY_SBEG        0x178   /* shifted beginning key         */
  885. #define KEY_SCANCEL     0x179   /* shifted cancel key            */
  886. #define KEY_SCOMMAND    0x17a   /* shifted command key           */
  887. #define KEY_SCOPY       0x17b   /* shifted copy key              */
  888. #define KEY_SCREATE     0x17c   /* shifted create key            */
  889. #define KEY_SDC         0x17d   /* shifted delete char key       */
  890. #define KEY_SDL         0x17e   /* shifted delete line key       */
  891. #define KEY_SELECT      0x17f   /* select key                    */
  892. #define KEY_SEND        0x180   /* shifted end key               */
  893. #define KEY_SEOL        0x181   /* shifted clear line key        */
  894. #define KEY_SEXIT       0x182   /* shifted exit key              */
  895. #define KEY_SFIND       0x183   /* shifted find key              */
  896. #define KEY_SHOME       0x184   /* shifted home key              */
  897. #define KEY_SIC         0x185   /* shifted input key             */
  898. #define KEY_SLEFT       0x187   /* shifted left arrow key        */
  899. #define KEY_SMESSAGE    0x188   /* shifted message key           */
  900. #define KEY_SMOVE       0x189   /* shifted move key              */
  901. #define KEY_SNEXT       0x18a   /* shifted next key              */
  902. #define KEY_SOPTIONS    0x18b   /* shifted options key           */
  903. #define KEY_SPREVIOUS   0x18c   /* shifted prev key              */
  904. #define KEY_SPRINT      0x18d   /* shifted print key             */
  905. #define KEY_SREDO       0x18e   /* shifted redo key              */
  906. #define KEY_SREPLACE    0x18f   /* shifted replace key           */
  907. #define KEY_SRIGHT      0x190   /* shifted right arrow           */
  908. #define KEY_SRSUME      0x191   /* shifted resume key            */
  909. #define KEY_SSAVE       0x192   /* shifted save key              */
  910. #define KEY_SSUSPEND    0x193   /* shifted suspend key           */
  911. #define KEY_SUNDO       0x194   /* shifted undo key              */
  912. #define KEY_SUSPEND     0x195   /* suspend key                   */
  913. #define KEY_UNDO        0x196   /* undo key                      */
  914.  
  915. /* PDCurses specific key definitions */
  916.  
  917. #define ALT_0           0x197   /* Alt-0                PC only  */
  918. #define ALT_1           0x198   /* Alt-1                PC only  */
  919. #define ALT_2           0x199   /* Alt-2                PC only  */
  920. #define ALT_3           0x19a   /* Alt-3                PC only  */
  921. #define ALT_4           0x19b   /* Alt-4                PC only  */
  922. #define ALT_5           0x19c   /* Alt-5                PC only  */
  923. #define ALT_6           0x19d   /* Alt-6                PC only  */
  924. #define ALT_7           0x19e   /* Alt-7                PC only  */
  925. #define ALT_8           0x19f   /* Alt-8                PC only  */
  926. #define ALT_9           0x1a0   /* Alt-9                PC only  */
  927. #define ALT_A           0x1a1   /* Alt-A                PC only  */
  928. #define ALT_B           0x1a2   /* Alt-B                PC only  */
  929. #define ALT_C           0x1a3   /* Alt-C                PC only  */
  930. #define ALT_D           0x1a4   /* Alt-D                PC only  */
  931. #define ALT_E           0x1a5   /* Alt-E                PC only  */
  932. #define ALT_F           0x1a6   /* Alt-F                PC only  */
  933. #define ALT_G           0x1a7   /* Alt-G                PC only  */
  934. #define ALT_H           0x1a8   /* Alt-H                PC only  */
  935. #define ALT_I           0x1a9   /* Alt-I                PC only  */
  936. #define ALT_J           0x1aa   /* Alt-J                PC only  */
  937. #define ALT_K           0x1ab   /* Alt-K                PC only  */
  938. #define ALT_L           0x1ac   /* Alt-L                PC only  */
  939. #define ALT_M           0x1ad   /* Alt-M                PC only  */
  940. #define ALT_N           0x1ae   /* Alt-N                PC only  */
  941. #define ALT_O           0x1af   /* Alt-O                PC only  */
  942. #define ALT_P           0x1b0   /* Alt-P                PC only  */
  943. #define ALT_Q           0x1b1   /* Alt-Q                PC only  */
  944. #define ALT_R           0x1b2   /* Alt-R                PC only  */
  945. #define ALT_S           0x1b3   /* Alt-S                PC only  */
  946. #define ALT_T           0x1b4   /* Alt-T                PC only  */
  947. #define ALT_U           0x1b5   /* Alt-U                PC only  */
  948. #define ALT_V           0x1b6   /* Alt-V                PC only  */
  949. #define ALT_W           0x1b7   /* Alt-W                PC only  */
  950. #define ALT_X           0x1b8   /* Alt-X                PC only  */
  951. #define ALT_Y           0x1b9   /* Alt-Y                PC only  */
  952. #define ALT_Z           0x1ba   /* Alt-Z                PC only  */
  953. #define CTL_LEFT        0x1bb   /* Control-Left-Arrow   PC only  */
  954. #define CTL_RIGHT       0x1bc   /* Control-Right-Arrow  PC only  */
  955. #define CTL_PGUP        0x1bd   /* Control-PgUp         PC only  */
  956. #define CTL_PGDN        0x1be   /* Control-PgDn         PC only  */
  957. #define CTL_HOME        0x1bf   /* Control-Home         PC only  */
  958. #define CTL_END         0x1c0   /* Control-End          PC only  */
  959. #define KEY_BACKTAB     0x1c1   /* Back-tab             PC only  */
  960.  
  961. #if defined(FLEXOS) || defined(XCURSES)
  962. #define KEY_MOUSE       0x1c2 /* "mouse" key  */
  963. #define KEY_A1          KEY_HOME/* upper left on Virtual keypad  */
  964. #define KEY_A2          KEY_UP  /* upper middle on Virt. keypad  */
  965. #define KEY_A3          KEY_PPAGE/* upper right on Vir. keypad   */
  966. #define KEY_B1          KEY_LEFT/* middle left on Virt. keypad   */
  967. #define KEY_B2          0x00    /* center on Virt. keypad        */
  968. #define KEY_B3          KEY_RIGHT/* middle right on Vir. keypad  */
  969. #define KEY_C1          KEY_LL  /* lower left on Virt. keypad    */
  970. #define KEY_C2          KEY_DOWN /* lower middle on Virt. keypad */
  971. #define KEY_C3          KEY_NPAGE /* lower right on Vir. keypad  */
  972. #define KEY_MAX         KEY_MOUSE /* Maximum curses key        */
  973. #endif
  974.  
  975.  
  976. #if defined(DOS)  || defined (OS2)
  977. #define KEY_A1          0x1c2   /* upper left on Virtual keypad  */
  978. #define KEY_A2          0x1c3   /* upper middle on Virt. keypad  */
  979. #define KEY_A3          0x1c4   /* upper right on Vir. keypad    */
  980. #define KEY_B1          0x1c5   /* middle left on Virt. keypad   */
  981. #define KEY_B2          0x1c6   /* center on Virt. keypad        */
  982. #define KEY_B3          0x1c7   /* middle right on Vir. keypad   */
  983. #define KEY_C1          0x1c8   /* lower left on Virt. keypad    */
  984. #define KEY_C2          0x1c9   /* lower middle on Virt. keypad  */
  985. #define KEY_C3          0x1ca   /* lower right on Vir. keypad    */
  986. #define PADSLASH        0x1cb   /* slash on keypad               */
  987. #define PADENTER        0x1cc   /* enter on keypad               */
  988. #define CTL_PADENTER    0x1cd   /* ctl-enter on keypad           */
  989. #define ALT_PADENTER    0x1ce   /* alt-enter on keypad           */
  990. #define SHF_PADSTOP     0x1cf   /* shift-stop on keypad          */
  991. #define PADSTAR         0x1d0   /* star on keypad                */
  992. #define PADMINUS        0x1d1   /* minus on keypad               */
  993. #define PADPLUS         0x1d2   /* plus on keypad                */
  994. #define CTL_PADSTOP     0x1d3   /* ctl-stop on keypad            */
  995. #define CTL_PADCENTER   0x1d4   /* ctl-enter on keypad           */
  996. #define CTL_PADPLUS     0x1d5   /* ctl-plus on keypad            */
  997. #define CTL_PADMINUS    0x1d6   /* ctl-minus on keypad           */
  998. #define CTL_PADSLASH    0x1d7   /* ctl-slash on keypad           */
  999. #define CTL_PADSTAR     0x1d8   /* ctl-star on keypad            */
  1000. #define ALT_PADPLUS     0x1d9   /* alt-plus on keypad            */
  1001. #define ALT_PADMINUS    0x1da   /* alt-minus on keypad           */
  1002. #define ALT_PADSLASH    0x1db   /* alt-slash on keypad           */
  1003. #define ALT_PADSTAR     0x1dc   /* alt-star on keypad            */
  1004. #define CTL_INS         0x1dd   /* ctl-insert                    */
  1005. #define ALT_DEL         0x1de   /* alt-delete                    */
  1006. #define ALT_INS         0x1df   /* alt-insert                    */
  1007. #define CTL_UP          0x1e0   /* ctl-up arrow                  */
  1008. #define CTL_DOWN        0x1e1   /* ctl-down arrow                */
  1009. #define CTL_TAB         0x1e2   /* ctl-tab                       */
  1010. #define ALT_TAB         0x1e3   /* alt-tab                       */
  1011. #define ALT_MINUS       0x1e4   /* alt-minus                     */
  1012. #define ALT_EQUAL       0x1e5   /* alt-equal                     */
  1013. #define ALT_HOME        0x1e6   /* alt-home                      */
  1014. #define ALT_PGUP        0x1e7   /* alt-pgup                      */
  1015. #define ALT_PGDN        0x1e8   /* alt-pgdn                      */
  1016. #define ALT_END         0x1e9   /* alt-end                       */
  1017. #define ALT_UP          0x1ea   /* alt-up arrow                  */
  1018. #define ALT_DOWN        0x1eb   /* alt-down arrow                */
  1019. #define ALT_RIGHT       0x1ec   /* alt-right arrow               */
  1020. #define ALT_LEFT        0x1ed   /* alt-left arrow                */
  1021. #define ALT_ENTER       0x1ee   /* alt-enter                     */
  1022. #define ALT_ESC         0x1ef   /* alt-escape                    */
  1023. #define ALT_BQUOTE      0x1f0   /* alt-back quote                */
  1024. #define ALT_LBRACKET    0x1f1   /* alt-left bracket              */
  1025. #define ALT_RBRACKET    0x1f2   /* alt-right bracket             */
  1026. #define ALT_SEMICOLON   0x1f3   /* alt-semi-colon                */
  1027. #define ALT_FQUOTE      0x1f4   /* alt-forward quote             */
  1028. #define ALT_COMMA       0x1f5   /* alt-comma                     */
  1029. #define ALT_STOP        0x1f6   /* alt-stop                      */
  1030. #define ALT_FSLASH      0x1f7   /* alt-forward slash             */
  1031. #define ALT_BKSP        0x1f8   /* alt-backspace                 */
  1032. #define CTL_BKSP        0x1f9   /* ctl-backspace                 */
  1033. #define CTL_PAD0        0x1fa   /* ctl-keypad 0                  */
  1034. #define CTL_PAD1        0x1fb   /* ctl-keypad 1                  */
  1035. #define CTL_PAD2        0x1fc   /* ctl-keypad 2                  */
  1036. #define CTL_PAD3        0x1fd   /* ctl-keypad 3                  */
  1037. #define CTL_PAD4        0x1fe   /* ctl-keypad 4                  */
  1038. #define CTL_PAD5        0x1ff   /* ctl-keypad 5                  */
  1039. #define CTL_PAD6        0x200   /* ctl-keypad 6                  */
  1040. #define CTL_PAD7        0x201   /* ctl-keypad 7                  */
  1041. #define CTL_PAD8        0x202   /* ctl-keypad 8                  */
  1042. #define CTL_PAD9        0x203   /* ctl-keypad 9                  */
  1043. #define CTL_DEL         0x204   /* clt-delete                    */
  1044. #define ALT_BSLASH      0x205   /* alt-back slash                */
  1045. #define CTL_ENTER       0x206   /* ctl-enter                     */
  1046. #define KEY_MOUSE       0x207 /* "mouse" key  */
  1047. #define KEY_MAX         KEY_MOUSE  /* Maximum curses key         */
  1048. #endif
  1049.  
  1050.  
  1051.  
  1052. /*----------------------------------------------------------------------
  1053. *       PDCurses function declarations
  1054. */
  1055. #ifdef ANSI
  1056. #  ifdef   CPLUSPLUS
  1057.      extern "C" {
  1058. #  endif
  1059. int     addchnstr( chtype *, int );
  1060. int     baudrate( void );
  1061. int     beep( void );
  1062. int     border( chtype, chtype, chtype, chtype, chtype, chtype, chtype, chtype );
  1063. char    breakchar( void );
  1064. int     can_change_color ( void );
  1065. int     clearok( WINDOW*, bool );
  1066. int     color_content( int, short*, short*, short* );
  1067. int     copywin( WINDOW*, WINDOW*, int, int, int, int, int, int, int );
  1068. int     curs_set( int );
  1069. int     cursoff( void );
  1070. int     curson( void );
  1071. int     def_prog_mode( void );
  1072. int     def_shell_mode( void );
  1073. int     delay_output(  int  );
  1074. int     delwin( WINDOW* );
  1075. WINDOW* derwin( WINDOW*, int, int, int, int );
  1076. int     doupdate( void );
  1077. WINDOW* dupwin( WINDOW* );
  1078. int     endwin( void );
  1079. char    erasechar( void );
  1080. int     fixterm( void );
  1081. int     flash( void );
  1082. int     flushinp( void );
  1083. int     gettmode( void );
  1084. bool    has_colors( void );
  1085. int     hline( chtype, int );
  1086. int     inchnstr( chtype *, int );
  1087. int     init_color( short, short, short, short );
  1088. int     init_pair( short, short, short );
  1089. WINDOW* initscr( void );
  1090. int     intrflush(  WINDOW*, bool  );
  1091. int     is_linetouched(WINDOW *,int);
  1092. int     is_wintouched(WINDOW *);
  1093. char*   keyname(  int  );
  1094. char    killchar( void );
  1095. char*   longname( void );
  1096. int     meta( WINDOW*, bool );
  1097. int     mvaddrawch( int, int, chtype );
  1098. int     mvaddrawstr( int, int, char* );
  1099. int     mvcur( int, int, int, int );
  1100. int     mvderwin( WINDOW*, int, int );
  1101. int     mvinsrawch( int, int, chtype );
  1102. int     mvprintw( int, int, char*,... );
  1103. int     mvscanw( int, int, char*,... );
  1104. int     mvwin( WINDOW*, int, int );
  1105. int     mvwinsrawch( WINDOW*, int, int, chtype );
  1106. int     mvwprintw( WINDOW*, int, int, char*,... );
  1107. int     mvwscanw( WINDOW*, int, int, char*,... );
  1108. WINDOW* newpad( int, int );
  1109. SCREEN* newterm( char*, FILE*, FILE* );
  1110. WINDOW* newwin( int, int, int, int );
  1111. int     noraw( void );
  1112. int     overlay( WINDOW*, WINDOW* );
  1113. int     overwrite( WINDOW*, WINDOW* );
  1114. int     pair_content( int, short*, short* );
  1115. int     pnoutrefresh( WINDOW*, int, int, int, int, int, int );
  1116. int     prefresh( WINDOW*, int, int, int, int, int, int );
  1117. int     printw( char*,... );
  1118. int     raw( void );
  1119. int     refresh( void );
  1120. int     reset_prog_mode( void );
  1121. int     reset_shell_mode( void );
  1122. int     resetterm( void );
  1123. int     resetty( void );
  1124. int     saveoldterm( void );
  1125. int     saveterm( void );
  1126. int     savetty( void );
  1127. int     scanw( char*,... );
  1128. int     scroll( WINDOW* );
  1129. SCREEN* set_term( SCREEN* );
  1130. int     start_color( void );
  1131. WINDOW* subpad( WINDOW*, int, int, int, int );
  1132. WINDOW* subwin( WINDOW*, int, int, int, int );
  1133. int     tabsize( int );
  1134. chtype  termattrs( void );
  1135. char*   termname( void );
  1136. int     touchline( WINDOW*, int ,int );
  1137. int     touchwin( WINDOW* );
  1138. int     typeahead( int );
  1139. char*   unctrl( chtype );
  1140. int     vline( chtype, int );
  1141. int     waddchnstr( WINDOW*, chtype*, int );
  1142. int     waddnstr( WINDOW*, char*, int );
  1143. int     waddrawstr( WINDOW*, char* );
  1144. int     waddstr( WINDOW*, char* );
  1145. int     wattroff( WINDOW*, chtype );
  1146. int     wattron( WINDOW*, chtype );
  1147. int     wattrset( WINDOW*, chtype );
  1148. int     wbkgd(WINDOW*, chtype);
  1149. void    wbkgdset(WINDOW*, chtype);
  1150. int     wborder( WINDOW*, chtype, chtype, chtype, chtype, chtype, chtype, chtype, chtype );
  1151. int     wclear( WINDOW* );
  1152. int     wclrtobot( WINDOW* );
  1153. int     wclrtoeol( WINDOW* );
  1154. int     wdelch( WINDOW* );
  1155. int     wdeleteln( WINDOW* );
  1156. int     werase( WINDOW* );
  1157. int     wgetch( WINDOW* );
  1158. int     wgetnstr( WINDOW*, char*, int );
  1159. int     wgetstr( WINDOW*, char* );
  1160. int     whline( WINDOW*, chtype, int );
  1161. int     winchnstr( WINDOW*, chtype*, int );
  1162. int     winnstr( WINDOW*, char*, int );
  1163. int     winsch( WINDOW*, chtype );
  1164. int     winsdelln( WINDOW*, int );
  1165. int     winsertln( WINDOW* );
  1166. int     winsnstr( WINDOW*, char*, int );
  1167. int     wmove( WINDOW*, int, int );
  1168. int     wnoutrefresh( WINDOW* );
  1169. char    wordchar( void );
  1170. int     wprintw( WINDOW*, char*,... );
  1171. int     wredrawln( WINDOW*, int ,int );
  1172. int     wrefresh( WINDOW* );
  1173. int     wscanw( WINDOW*, char*,... );
  1174. int     wscrl( WINDOW*, int );
  1175. int     wsetscrreg( WINDOW*, int, int );
  1176. int     wtabsize( WINDOW*, int );
  1177. int     wtouchln(WINDOW *, int, int, int);
  1178. int     ungetch( int );
  1179. int     wvline( WINDOW*, chtype, int );
  1180.  
  1181. #ifdef     PDCURSES
  1182. int     raw_output( bool );
  1183. int     resize_screen( int );
  1184. WINDOW* resize_window( WINDOW*, int, int );
  1185. int     win_print( WINDOW*, int );
  1186. #endif
  1187.  
  1188. /*
  1189. *       Keep the compiler happy with our macros below...
  1190. */
  1191. int     PDC_chadd( WINDOW*, chtype, bool, bool );
  1192. int     PDC_chins( WINDOW*, chtype, bool );
  1193.  
  1194. #  ifdef   CPLUSPLUS
  1195.      }
  1196. #  endif
  1197. #endif
  1198.  
  1199.  
  1200. #ifndef max
  1201. #define max(a,b) (((a) > (b)) ? (a) : (b))
  1202. #endif
  1203. #ifndef min
  1204. #define min(a,b) (((a) < (b)) ? (a) : (b))
  1205. #endif
  1206.  
  1207. /*
  1208. *       Functions defined as macros
  1209. */
  1210.  
  1211. #define addch( c )              waddch( stdscr, c )
  1212. #define addchstr( c )           addchnstr( c, -1 )
  1213. #define addstr(str)             waddstr( stdscr, str )
  1214. #define addnstr(str, n)         waddnstr( stdscr, str, n )
  1215. #define attroff(attr)           wattroff( stdscr, attr )
  1216. #define attron(attr)            wattron( stdscr, attr )
  1217. #define attrset(attr)           wattrset( stdscr, attr )
  1218. #define bkgd(c)                 wbkgd(stdscr,c)
  1219. #define bkgdset(c)              wbkgdset(stdscr,c)
  1220. #define border(ls,rs,ts,bs,tl,tr,bl,br)  wborder(stdscr,ls,rs,ts,bs,tl,tr,bl,br)
  1221. #define box( w, v, h )          wborder( w, v, v, h, h, 0, 0, 0, 0 )
  1222. #define clear()                 (clearok( stdscr, TRUE )==ERR?ERR:wclear( stdscr ))
  1223. #define clrtobot()              wclrtobot( stdscr )
  1224. #define clrtoeol()              wclrtoeol( stdscr )
  1225. #define delch()                 wdelch( stdscr )
  1226. #define deleteln()              wdeleteln( stdscr )
  1227. #define derwin(w,nl,nc,by,bx)   subwin((w),(nl),(nc),(by+(w)->_begy),(bx+(w)->_begx))
  1228. #define echochar(c)             (addch((chtype)c)==ERR?ERR:refresh())
  1229. #define erase()                 werase( stdscr )
  1230. #define getbegx(w)              (w)->_begx
  1231. #define getbegy(w)              (w)->_begy
  1232. #define getbegyx(w,y,x)         ( y = (w)->_begy, x = (w)->_begx )
  1233. #define getch()                 wgetch(stdscr)
  1234. #define getmaxx(w)              (w)->_maxx
  1235. #define getmaxy(w)              (w)->_maxy
  1236. #define getmaxyx(w,y,x)         ( y = (w)->_maxy, x = (w)->_maxx )
  1237. #define getparx(w)              (w)->_parx
  1238. #define getpary(w)              (w)->_pary
  1239. #define getparyx(w,y,x)         ( y = (w)->_pary, x = (w)->_parx )
  1240. #define getstr(str)             wgetstr( stdscr, str )
  1241. #define getyx(w,y,x)            ( y = (w)->_cury, x = (w)->_curx )
  1242. #define has_colors()            ((_cursvar.mono) ? FALSE : TRUE)
  1243. #define idcok(w,flag)           OK
  1244. #define idlok(w,flag)           OK
  1245. #define inch()                  (stdscr->_y[stdscr->_cury][stdscr->_curx])
  1246. #define inchstr( c )            inchnstr( c, stdscr->_maxx-stdscr->_curx )
  1247. #define innstr(str,n)           winnstr(stdscr,(str),(n))
  1248. #define insch( c )              winsch( stdscr, c )
  1249. #define insdelln(n)             winsdelln(stdscr,n)
  1250. #define insertln()              winsertln( stdscr )
  1251. #define insnstr(s,n)            winsnstr(stdscr,s,n)
  1252. #define insstr(s)               winsnstr(stdscr,s,(-1))
  1253. #define instr(str)              winnstr(stdscr,(str),stdscr->_maxx)
  1254. #define isendwin()              ((_cursvar.alive) ? FALSE : TRUE)
  1255. #define keypad(w,flag)          (w->_use_keypad  = flag)
  1256. #define leaveok(w,flag)         (w->_leave   = flag)
  1257. #define move(y,x)               wmove( stdscr, y, x )
  1258. #define mvaddch(y,x,c)          (move( y, x )==ERR?ERR:addch( c ))
  1259. #define mvaddchstr(y,x,c)       (move( y, x )==ERR?ERR:addchnstr( c, -1 ))
  1260. #define mvaddchnstr(y,x,c,n)    (move( y, x )==ERR?ERR:addchnstr( c, n ))
  1261. #define mvaddstr(y,x,str)       (move( y, x )==ERR?ERR:addstr( str ))
  1262. #define mvdelch(y,x)            (move( y, x )==ERR?ERR:wdelch( stdscr ))
  1263. #define mvgetch(y,x)            (move( y, x )==ERR?ERR:wgetch(stdscr))
  1264. #define mvgetstr(y,x,str)       (move( y, x )==ERR?ERR:wgetstr( stdscr, str ))
  1265. #define mvinch(y,x)             (move( y, x )==ERR?ERR:(stdscr->_y[y][x]))
  1266. #define mvinchstr(y,x,c)        (move( y, x )==ERR?ERR:inchnstr( c, stdscr->_maxx-stdscr->_curx ))
  1267. #define mvinchnstr(y,x,c,n)     (move( y, x )==ERR?ERR:inchnstr( c, n ))
  1268. #define mvinsch(y,x,c)          (move( y, x )==ERR?ERR:winsch( stdscr, c ))
  1269. #define mvinsnstr(y,x,s,n)      (move( y, x )==ERR?ERR:winsnstr(stdscr,s,n))
  1270. #define mvinsstr(y,x,s)         (move( y, x )==ERR?ERR:winsnstr(stdscr,s,(-1)))
  1271. #define mvinstr(y,x,str)        (move( y, x )==ERR?ERR:winnstr(stdscr,(str),stdscr->_maxx))
  1272. #define mvinnstr(y,x,str,n)     (move( y, x )==ERR?ERR:winnstr(stdscr,(str),(n)))
  1273. #define mvwaddch(w,y,x,c)       (wmove( w, y, x )==ERR?ERR:waddch( w, c ))
  1274. #define mvwaddchstr(w,y,x,c)    (wmove( w, y, x )==ERR?ERR:waddchnstr( w, c, -1 ))
  1275. #define mvwaddchnstr(w,y,x,c,n) (wmove( w, y, x )==ERR?ERR:waddchnstr( w, c, n ))
  1276. #define mvwaddrawch(w,y,x,c)    (wmove( w, y, x )==ERR?ERR:waddrawch( w, c ))
  1277. #define mvwaddrawstr(w,y,x,str) (wmove( w, y, x )==ERR?ERR:waddrawstr( w, str ))
  1278. #define mvwaddstr(w,y,x,str)    (wmove( w, y, x )==ERR?ERR:waddstr( w, str ))
  1279. #define mvwdelch(w,y,x)         (wmove( w, y, x )==ERR?ERR:wdelch( w ))
  1280. #define mvwgetch(w,y,x)         (wmove( w, y, x )==ERR?ERR:wgetch( w ))
  1281. #define mvwgetstr(w,y,x,str)    (wmove( w, y, x )==ERR?ERR:wgetstr( w, str ))
  1282. #define mvwinch(w,y,x)          (wmove( w, y, x )==ERR?ERR:((w)->_y[y][x]))
  1283. #define mvwinchstr(w,y,x,c)     (wmove( w, y, x )==ERR?ERR:winchnstr( w, c, (w)->_maxx-(w)->_curx ))
  1284. #define mvwinchnstr(w,y,x,c,n)  (wmove( w, y, x )==ERR?ERR:winchnstr( w, c, n ))
  1285. #define mvwinsch(w,y,x,c)       (wmove( w, y, x )==ERR?ERR:winsch( w, c ))
  1286. #define mvwinstr(w,y,x,str)     (wmove( w, y, x )==ERR?ERR:winnstr(w,str,(w)->_maxx))
  1287. #define mvwinnstr(w,y,x,str,n)  (wmove( w, y, x )==ERR?ERR:winnstr(w,str,n))
  1288. #define mvwinsnstr(w,y,x,s,n)   (wmove( w, y, x )==ERR?ERR:winsnstr(w,s,n))
  1289. #define mvwinsstr(w,y,x,s)      (wmove( w, y, x )==ERR?ERR:winsnstr(w,s,(-1)))
  1290. #define napms(ms)               delay_output(ms)
  1291. #define nl()                    (_cursvar.autocr = TRUE)
  1292. #define nonl()                  (_cursvar.autocr = FALSE)
  1293. #define notimeout(w,flag)       (OK)
  1294. #define pechochar(w,c)          (waddch(w,(chtype)c)==ERR?ERR:prefresh(w))
  1295. #define redrawwin(w)            wredrawln((w),0,(win)->_maxy)
  1296. #define refrbrk(flag)           (_cursvar.refrbrk = flag)
  1297. #define refresh()               wrefresh( stdscr )
  1298. #define scrl(n)                 wscrl(stdscr,n)
  1299. #define scroll(w)               wscrl((w),1)
  1300. #define scrollok(w,flag)        ((w)->_scroll  = flag)
  1301. #define setscrreg(top, bot)     wsetscrreg( stdscr, top, bot )
  1302. #define standend()              wattrset(stdscr, A_NORMAL)
  1303. #define standout()              wattrset(stdscr, A_STANDOUT)
  1304. #define touchline(w,y,n)        wtouchln((w),(y),(n),TRUE)
  1305. #define touchwin(w)             wtouchln((w),0,(w)->_maxy,TRUE)
  1306. #define traceoff()              {trace_on = FALSE;}
  1307. #define traceon()               {trace_on = TRUE;}
  1308. #define untouchwin(w)           wtouchln((w),0,((w)->_maxy),FALSE)
  1309. #define waddch(w, c)            PDC_chadd( w, (chtype)c, (bool)!(_cursvar.raw_out), TRUE )
  1310. #define waddchstr(w, c)         (waddchnstr( w, c, -1 ) )
  1311. #define wclear(w)               ( werase( w )==ERR?ERR:((w)->_clear = TRUE))
  1312. #define wechochar(w,c)          (waddch(w,(chtype)c)==ERR?ERR:wrefresh(w))
  1313. #define winch(w)                ((w)->_y[(w)->_cury][(w)->_curx])
  1314. #define winchstr(w, c)          (winchnstr( w, c, (w)->_maxx-(w)->_curx ) )
  1315. #define winsstr(w,str)          winsnstr((w),(str),(-1))
  1316. #define winstr(w,str)           winnstr((w),str,(w)->_maxx)
  1317. #define wstandend(w)            wattrset(w, A_NORMAL)
  1318. #define wstandout(w)            wattrset(w, A_STANDOUT)
  1319.  
  1320. #ifndef UNIX
  1321. #define cbreak()                (_cursvar.cbreak = TRUE)
  1322. #define nocbreak()              (_cursvar.cbreak = FALSE)
  1323. #define crmode()                (_cursvar.cbreak = TRUE)
  1324. #define nocrmode()              (_cursvar.cbreak = FALSE)
  1325. #define echo()                  (_cursvar.echo = TRUE)
  1326. #define noecho()                (_cursvar.echo = FALSE)
  1327. #define nodelay(w,flag)         (w->_nodelay = flag)
  1328. #endif
  1329.  
  1330. #ifdef     PDCURSES
  1331. #define addrawch( c )           waddrawch( stdscr, c )
  1332. #define addrawstr(str)          waddrawstr( stdscr, str )
  1333. #define insrawch( c )           winsrawch( stdscr, c )
  1334. #define waddrawch(w, c)         PDC_chadd( w, (chtype)c, FALSE, TRUE )
  1335. #define winsrawch(w, c)         PDC_chins( w, (chtype)c, FALSE )
  1336.  
  1337. /*
  1338.  *      FYI: Need to document these functions...
  1339.  */
  1340. #define title(s,a)              wtitle( stdscr, s, (chtype)a )
  1341. #define titleofs(ofs)           wtitleofs( stdscr, ofs )
  1342. #define wtitle(w,s,a)           (w->_title = s, w->_title_attr = (chtype)a)
  1343. #define wtitleofs(w,ofs)        (w->_title_ofs = ofs)
  1344. #endif
  1345.  
  1346. /*
  1347.  *      Load up curspriv.h.     This should be in the same place as
  1348.  *      stdlib.h.  We allow anyone who defines CURSES_LIBRARY to have
  1349.  *      access to our internal routines.  This provides quick
  1350.  *      PC applications at the expense of portability.
  1351.  */
  1352. #if defined     (CURSES_LIBRARY) | defined( INTERNAL)
  1353. #  include <curspriv.h>
  1354. #  include <stdlib.h>
  1355. #endif
  1356.  
  1357. #endif  /* __PDCURSES__ */
  1358.